package com.example.oldkingdom.areas;

import java.util.HashMap;


import android.content.res.Resources;
import android.graphics.drawable.Drawable;

import com.example.oldkingdom.R;

import com.example.oldkingdom.activities.Explore;
import com.example.oldkingdom.base.worldPoint;
import com.example.oldkingdom.entities.spawner;
import com.example.oldkingdom.items.item;

public class areas 
{
	public areas()
	{

	}
	public static areas getInstance()
	{
		if (_instance == null)
		{
			_instance = new areas();
			_instance.init();
		}
		
		return _instance;
	}
	public void init()
	{
		mapArea townSquare = new mapArea().setDesc("The Town Square").setWorldPoint(0,0);
		/*
		new mapArea().setDesc("The Town Square - South Gate").setWorldPoint(0, 1);
		new mapArea().setDesc("The Town Square - North Gate").setWorldPoint(0,-1);
		new mapArea().setDesc("The Town Square - East Gate").setWorldPoint(1, 0);
		new mapArea().setDesc("The Town Square - West Gate").setWorldPoint(-1, 0);
		*/
		Resources res = Explore.Instance.getResources();
		Drawable snow = res.getDrawable(R.drawable.snow);
		Drawable town = res.getDrawable(R.drawable.town);
		mapArea townSquareS = new mapArea().setDesc("The Town Square - South Gate").setWorldPoint(townSquare.WorldPoint.plus(worldPoint.South)).setBackground(town);
		mapArea townSquareN = new mapArea().setDesc("The Town Square - North Gate").setWorldPoint(townSquare.WorldPoint.plus(worldPoint.North)).setBackground(town);
		mapArea townSquareE = new mapArea().setDesc("The Town Square - East Gate").setWorldPoint(townSquare.WorldPoint.plus(worldPoint.East)).setBackground(town).addItem(item.paper.getName()).addItem(item.paper.getName());
		mapArea townSquareW = new mapArea().setDesc("The Town Square - West Gate").setWorldPoint(townSquare.WorldPoint.plus(worldPoint.West)).setBackground(town);
		mapArea townOutSouthGate = new mapArea().setDesc("Snowy Apple Tree Yard").setWorldPoint(townSquareS.WorldPoint.plus(worldPoint.South)).setBackground(snow).addSpawner(spawner.appleTree);
		
		
	}
	public void addArea(worldPoint wp, mapArea wa)
	{
		mapAreas.put(wp.getHash(),wa);
	}
	public mapArea getArea(worldPoint wp)
	{
		if (mapAreas.containsKey(wp.getHash()))
			return mapAreas.get(wp.getHash());
		
		return null;
	}
	
	private static areas _instance;
	private HashMap<Integer, mapArea> mapAreas = new HashMap<Integer, mapArea>();
}
